package development;

import java.util.Hashtable;

import javax.microedition.lcdui.Image;

import state.GameForm;
import state.Sprite;
import state.TouchScreenListener;
import state.util.ImageUtil;

public class FrmTestTouchScreen extends GameForm {
  private Image buttonImage;
  private Image lightButtonImage;

  private Sprite buttonSprite;

  public void init(Hashtable parameters) {
    buttonImage = ImageUtil.getImage("button_nho.png");
    lightButtonImage = ImageUtil.makeBrighter(buttonImage, 4);

    buttonSprite = new Sprite(buttonImage, manager, 50, 50);
    buttonSprite.setTouchScreenListener(new TouchScreenListener() {
      public void pointerReleased(Sprite source, int x, int y) {
        if (source.getImage() == buttonImage) {
          source.setImage(lightButtonImage);
        } else {
          source.setImage(buttonImage);
        }
      }

      public void pointerPressed(Sprite source, int x, int y) {
      }

      public void pointerDragged(Sprite source, int x, int y) {
        source.setPosition(x - source.getWidth() / 2, y - source.getHeight() / 2);
      }
    });
  }

  protected void destroy() {
  }
}
